﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DTO;
using BUS;
namespace MasterPageGroupF3
{
    public partial class DoiThongTinDoanhNghiep : System.Web.UI.Page
    {

        protected void Page_Load(object sender, EventArgs e)
        {

            PROVIDER  prvd = PROVIDERBUS.LayProviderCoUser((String)Session ["Provider"]);
            TenDN.Text = prvd.NAME;
            DiaChi.Text = prvd.ADDRESS;
            DienThoai.Text = prvd.PHONE;
            Intro.Text = prvd.INTRODUCE_COMPANY;

            // phan sua giao dien
            if (Session["Provider"] != null)
            {
                Label lbTaiKhoan = (Label)this.Master.FindControl("lbTaiKhoan");
                lbTaiKhoan.Text = Session["Provider"].ToString();
                Label lbLogout = (Label)this.Master.FindControl("lbLogout");
                lbLogout.Text = "<li><img src=\"../skin/frontend/default/inspire-blue/images/citydivider.jpg\"/></li>" +
                    "<li class=\"first\"><a href=\"index.aspx?logout=true\">Thoát</a></li>";
                Label lbDangKy = (Label)this.Master.FindControl("lbDangKy");
                lbDangKy.Text = "";
            }
            if (Request.QueryString["logout"] != null)
            {
                if (Request.QueryString["logout"].ToString().Equals("true"))
                {
                    Session.RemoveAll();
                }
            }

        }
        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            PROVIDER prvd = PROVIDERBUS.LayProviderCoUser((String)Session["Provider"]);
            if (prvd.PASSWORD != CurPass.Text)
            {
                Response.Write("<script language='javascript'>alert('Password không đúng. Vui lòng nhập lại');</script>");
                return;
            }
            prvd.NAME = TenDN.Text;
            prvd.PHONE = DienThoai.Text;
            prvd.ADDRESS = DiaChi.Text;
            prvd.INTRODUCE_COMPANY = Intro.Text;
            prvd.PASSWORD = NewPass.Text;
            PROVIDERBUS probus = new PROVIDERBUS();

            probus.Update_Info(prvd);
            Response.Write("<script language='javascript'>alert('Cập Nhật Thành công');</script>");
            Response.Redirect("~/ho-chi-minh/index.aspx");
        }
    }
}